class student():
    def age_get(self):
        return self._age
    def age_set(self,age):
        if age < 0:
            raise Exception('age 数值错误')
        self._age = age
    age = property(fget=age_get, fset=age_set)  # 通过类属性的方式去使用 property类的实例

s = student()
s.age = 18
print(s.age)


